﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Sqlite;

namespace TodoMVC.DBServices
{
    public static class ConnectionHelper
    {
        public static string GetBasePath()
        {
            var basePath = Path.Combine(Environment.CurrentDirectory, "database");
            
            if (!Directory.Exists(basePath))
            {
                Directory.CreateDirectory(basePath);
            }
            return basePath;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static string GetSqliteConnectionString()
        {
            var connectionStringBuilder = new SqliteConnectionStringBuilder();
            var basePath = GetBasePath();
            connectionStringBuilder.DataSource = Path.Combine(basePath, "todomvc.db3");
            return connectionStringBuilder.ToString();
        }
        public static string GetSqliteBackupConnectionString()
        {
            var connectionStringBuilder = new SqliteConnectionStringBuilder();
            var basePath = GetBasePath();
            connectionStringBuilder.DataSource = Path.Combine(basePath, "todomvc.db3.bakup");
            return connectionStringBuilder.ToString();
        }
    }
}
